from bases.atest_fail_tops import AtestFailTops
from cases import main_cases_length
from windows.left_windows import top_ids, top_nums
from 其他.tk_base_widgets.tk调试.字符串匹配方式与排序 import complete_list


class CaseFailConfig:
    fail_config:AtestFailTops = AtestFailTops()
    length:int = 0
    @classmethod
    def init(cls):      # 获取到main_case的数量，然后进行初始化
        ids = []
        cls.length = main_cases_length[0]   # 获取用例数量
        cls.create_main_id(ids)
        cls.fail_config.add_main_cases_init(ids)
        # print(ids)    # 已确定成功生成对应字典。
        # print(cls.fail_config.get_fail_top_dict())

    @classmethod
    def a(cls):
        pass

    @classmethod
    def create_main_id(cls, l:list, key:str='main'):
        for i in range(1, cls.length+1):
            s = key+'_'+str(i).rjust(2,'0')
            l.append(s)

    @classmethod
    def sorted_top_fail_GUI_update(cls, fail_id):   # 格式 main_01
        # print('asdxxxxxxxxxxxxxxxxxxxxxxx', fail_id)
        cls.fail_config.add_item(fail_id)
        ids_nums = cls.fail_config.get_sorted()
        # print('asss', ids_nums)
        for i in range(min(cls.length,5)):
            if ids_nums[i][1] != 0:
                top_ids[i].set(ids_nums[i][0])
                top_nums[i].set(ids_nums[i][1])
